Skip to content

Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement#36680

Merged
strongduanmu merged 6 commits into
apache:masterfrom
chakkk309:optimize-MySQL-INSERT-INTO-VALUES-AS-row_alias-parse-SQLStatement
Dec 20, 2025
Merged

Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement#36680
strongduanmu merged 6 commits into
apache:masterfrom
chakkk309:optimize-MySQL-INSERT-INTO-VALUES-AS-row_alias-parse-SQLStatement

Conversation

@chakkk309
Copy link
Copy Markdown
Contributor

@chakkk309 chakkk309 commented Sep 24, 2025

Fixes #36583.

Changes proposed in this pull request:


Before committing this PR, I'm sure that I have checked the following options:

  • My code follows the code of conduct of this project.
  • I have self-reviewed the commit code.
  • I have (or in comment I request) added corresponding labels for the pull request.
  • I have passed maven check locally : ./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e.
  • I have made corresponding changes to the documentation.
  • I have added corresponding unit tests for my changes.
  • I have updated the Release Notes of the current development version. For more details, see Update Release Note

: INSERT insertSpecification INTO? tableName partitionNames? insertBody onDuplicateKeyClause? returningClause?
;

insertBody : insertValuesClause | setAssignmentsClause valueReference? | insertSelectClause valueReference? ;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put the content after : on a new line.

result.setInsertColumns(new InsertColumnsSegment(ctx.start.getStartIndex() - 1, ctx.start.getStartIndex() - 1, Collections.emptyList()));
}
result.getValues().addAll(createInsertValuesSegments(ctx.assignmentValues()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove useless blank line.

ValueReferenceSegment valueRef = (ValueReferenceSegment) visit(ctx.valueReference());
result.setValueReference(valueRef);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove useless blank line.


@Override
public ASTNode visitRowAlias(final RowAliasContext ctx) {
return new CommonExpressionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.getText());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why return CommonExpressionSegment?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May use RowAliasSegment here is better.

}
return new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
SetAssignmentSegment setAssignment = new SetAssignmentSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), assignments);
return setAssignment;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove setAssignment and return new xxx directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@chakkk309
Copy link
Copy Markdown
Contributor Author

Hi @strongduanmu , this pr is ready to review~

@strongduanmu
Copy link
Copy Markdown
Member

Hi @strongduanmu , this pr is ready to review~

Ok, I will review this pr later.

@chakkk309
Copy link
Copy Markdown
Contributor Author

cc @strongduanmu this pr ready for review :)

Copy link
Copy Markdown
Member

@strongduanmu strongduanmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, merged.

@strongduanmu strongduanmu merged commit b5218e8 into apache:master Dec 20, 2025
145 checks passed
@chakkk309 chakkk309 deleted the optimize-MySQL-INSERT-INTO-VALUES-AS-row_alias-parse-SQLStatement branch December 20, 2025 04:48
makssent pushed a commit to makssent/shardingsphere that referenced this pull request Apr 9, 2026
…ngsphere/master

* remotes/origin/master:
  Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement (apache#36680)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize MySQL INSERT INTO VALUES AS row_alias parse SQLStatement

2 participants